{% extends "base.html" %}
{% load i18n %}
{% block content %}

<div class="page-header">
  <h1>Hosts</h1>
</div>

<ol class="breadcrumb">
  <li><a href="{% url 'service-list' %}">Home</a></li>
  <li class="active">Search</li>
</ol>

{% if service_list %}
<div class="panel panel-default">
  <div class="panel-heading">Services</div>
  <table class="table table-bordered table-condensed">
    <tr>
      <th>Name</th>
      <th>Projects</th>
      <th>Rules</th>
    </tr>
    {% for service in service_list %}
    <tr>
      <td><a href="{% url 'service-detail' service.id %}">{{ service.name }}</a></td>
      <td>
        <ul class="list-unstyled">
        {% for project in service.project_set.all %}
          <li><a href="{% url 'project-detail' project.id %}">{{ project.name }}</a></li>
        {% endfor %}
        </ul>
      </td>
      <td>
        <ul class="list-unstyled">
        {% for rule in service.rule_set.all %}
          <li><a href="{% url 'rule-detail' rule.id %}">{{ rule.name }}</a></li>
        {% endfor %}
        </ul>
      </td>
    </tr>
    {% endfor %}
  </table>
</div>
{% endif %}

{% if project_list %}
<div class="panel panel-default">
  <div class="panel-heading">Projects</div>
  <table class="table table-bordered table-condensed">
    <tr>
      <th class="col-md-2">Project</th>
      <th class="col-md-3">Exporters</th>
      <th class="col-md-3">Notifiers</th>
      <th class="col-md-1">Actions</th>
    </tr>
    {% for project in project_list %}
    {% include 'promgen/project_row.html' %}
    {% endfor %}
  </table>
</div>
{% endif %}

{% if farm_list %}
<div class="panel panel-default">
  <div class="panel-heading">Farms</div>
  <table class="table table-bordered table-condensed">
    <tr>
      <th>Name</th>
      <th>Projects</th>
      <th>Hosts</th>
    </tr>
    {% for farm in farm_list %}
    <tr>
      <td><a href="{% url 'farm-detail' farm.id %}">{{ farm.name }}</a></td>
      <td>
        <ul class="list-unstyled">
{% for project in farm.project_set.all %}
          <li><a href="{% url 'project-detail' project.id %}">{{ project.name }}</a></li>
{% endfor %}
        </ul>
      </td>
      <td>
        <ul class="list-unstyled">
{% for host in farm.host_set.all %}
          <li>
            <a href="{% url 'host-detail' host.name %}">{{ host.name }}</a>
            <a
            @click.prevent="silenceSetLabels"
            class="btn btn-warning btn-xs"
            data-instance="{{host.name}}:[0-9]*"
            href="#"
            style="display: inline-block;"
          >{% trans "Silence" %}</a></li>
{% endfor %}
        </ul>
      </td>
    </tr>
    {% endfor %}
  </table>
</div>
{% endif %}

{% if host_list %}
<div class="panel panel-default">
  <div class="panel-heading">Hosts</div>
  <table class="table">
    {% for host in host_list %}
      <tr>
        <td><a href="{% url 'host-detail' host.name %}">{{ host.name }}</a></td>
        <td><a
          @click.prevent="silenceSetLabels"
          class="btn btn-warning btn-xs"
          data-instance="{{host.name}}:[0-9]*"
          href="#"
          style="display: inline-block;"
        >{% trans "Silence" %}</a></td>
      </tr>
    {% endfor %}
  </table>
</div>
{% endif %}

{% if rule_list %}
<div class="panel panel-default">
  <div class="panel-heading">Rules</div>
  <table class="table table-bordered table-condensed">
    {% include "promgen/rule_header.html" %}
    {% include "promgen/rule_block.html" %}
  </table>
</div>
{% endif %}

{% endblock %}
